(library (list-procs)
  (export recursive-member
          rest)
  (import (rnrs base)
          (only (guile)
                lambda* λ)
          ;; GNU Guile batteries
          (ice-9 exceptions)
          ;; SRFIs
          ;; SRFI 1 - list procs
          (srfi srfi-1)))


(define rest
  (λ (lst)
    (cdr lst)))


(define recursive-member
  (λ (seeked lst test-proc)
    (cond
     [(null? lst) #f]
     [(pair? (first lst))
      (or (recursive-member seeked (first lst) test-proc)
          (recursive-member seeked (rest lst) test-proc))]
     [(test-proc (first lst) seeked)
      lst]
     [else
      (recursive-member seeked (rest lst) test-proc)])))
